<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../../css/mui.min.css" rel="stylesheet" />
		<style type="text/css">
			.top-button{float: right;margin-top: 2.5%;margin-right: -3%;border: 0;background-color: #F7F7F7;color: #007AFF;}
			.mui-btn-primary:active{background-color: #F7F7F7 !important;border: 0!important;}
			.mui-content .mui-input-clear{margin-bottom: 0;border: 0;padding: 8% 5%;margin-top: 5%;}

		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav" id="header">
		    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
		    <h1 class="mui-title">修改昵称</h1>
		    <button class="top-button mui-btn-primary" id="buttonm">完成</button>
		</header>
		
		
		<div class="mui-content">
            <input type="text" class="mui-input-clear" placeholder="破解机" id="inputt"/> 
		</div>
		
		
		
		<script src="../../js/mui.min.js"></script>
		<script src="../../js/immersed.js" ></script>
		<script type="text/javascript">
			mui.init();
			
			window.onload = function(){
			mui.plusReady(function(){
				starbar();
				plus.navigator.setStatusBarStyle('dark');
				
				var Data = plus.webview.currentWebview();
				var nick = document.getElementById('inputt');
				var cont = document.getElementById('inputt');
				 nick.value = Data.nick;
			    document.getElementById('buttonm').addEventListener('tap',function(){
					if (nick.value == "") {
						mui.alert('昵称不能为空！');
					} else{
					    mui.ajax({
							url: 'https://www.lunyuwang.com/mineController/updataNickName',
							data: {	
								lyuser_Card: plus.storage.getItem("card"),	
								lyuser_NickName: cont.value
							},
							async: true, //将false改为true
							crossDomain: true, //强制使用5+跨域
							dataType: 'json', //服务器返回json格式数据
							type: 'get', //HTTP请求类型
							timeout: 10000, //超时时间设置为10秒；
							//processData: false,
							headers: {
								'Content-Type': 'application/x-www-form-urlencoded'
							},
							success: function(data) {
								if(data.state == 1){
									var preView = plus.webview.currentWebview().opener(); //触发上一个页面刷新图片事件
		                         	mui.fire(preView,'install',{ 
		                         		nickname:  cont.value
		                         	}); 
		                         	mui.back();
								}
							},
							error: function(xhr, type, errorThrown) {
								//异常处理；
								mui.toast("修改失败了哦！")	
						    }
					    })
					}
                })
			})
		}
		</script>
	</body>

</html>